import { createSlice } from '@reduxjs/toolkit'

const userStore = createSlice({
    name: 'user',
    initialState: {
        token: localStorage.getItem('token') || '',
        userInfo: {},
        isLogin: false
    },
    reducers: {
        tokenReducer(state, action) {
            return { ...state, token: action.payload.token }
        },
        userInfoReducer(state, action) {
            return { ...state, userInfo: action.payload.userInfo }
        },
        isLoginReducer(state, action) {
            return { ...state, isLogin: action.payload.isLogin }
        }
    }
})

export default userStore.reducer